import postApi from '../../utils/http/api'
import postApiNew from "../../utils/http/api-new";

export default {
  //16.2用户可获取证书列表
  //证书！==计划，，计划学完才能领取证书
  getMyUserCertificationList (targetUserid) {
    return postApi({
      actionCode: '500101',
      method: 'getUserReceiveCertificateList',
      requestData: {
        targetUserid
      },
    }).then((result) => {
      let list = result.responseData.list
      list = list.filter(item => item.isReceive === 1)
      list = list.map(item => {
        let pic = item.pic
        let index = pic.lastIndexOf('.')
        let suffix = pic.substring(index, pic.length)
        item.smallPic = pic + '.small' + suffix
        return item
      })
      result.responseData.list = list
      return result
    })
  },
  // 查看证书
  getCertDetail (certId, userId) {
    return postApi({
      actionCode: '500101',
      method: 'getCertificateInfoById',
      requestData: {
        'targetUserid': userId,
        'id': certId
      },
    })

  },

  //企业大学新版接口 2020.11.3 lee


  //计划列表 2.1 企业计划列表接口
  getPlanList() {
    return postApiNew({
      actionCode: "zhiye-media",
      path: "/level/plan/getLevelMainPlanList",
      requestData: {},
    })
  },

  //2.2 企业计划详情接口
  getPlanDetail(id) {
    return postApiNew({
      actionCode: "zhiye-media",
      path: "/level/plan/getOrgLevelPlanDetailById",
      requestData: {
        'id': id,
      },
    })
  },

  //2.3 企业计划领取证书
  submitCertificate (planId, certificateId) {
    return postApiNew({
      actionCode: "zhiye-media",
      path: "/level/plan/submitUserPlanCertificateLogById",
      requestData: {
        planId,
        certificateId
      },
    })
  },
}
